<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0080)http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170459&showall=true -->
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
<link rel="stylesheet" type="text/css" href="./OCPJP 6 - Exam Simulator  Collections nightmare_files/styles.php">
<link rel="stylesheet" type="text/css" href="./OCPJP 6 - Exam Simulator  Collections nightmare_files/styles(1).php">

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="http://www.whizlabs.com/examprep/theme/standard/styles_ie7.css" />
<![endif]-->
<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="http://www.whizlabs.com/examprep/theme/standard/styles_ie6.css" />
<![endif]-->


    <meta name="keywords" content="moodle, OCPJP 6 - Exam Simulator: Collections nightmare ">
    <title>OCPJP 6 - Exam Simulator: Collections nightmare</title>
    <link rel="shortcut icon" href="http://www.whizlabs.com/examprep/theme/ability-to-learn/favicon.ico">
    <!--<style type="text/css">/*<![CDATA[*/ body{behavior:url(http://www.whizlabs.com/examprep/lib/csshover.htc);} /*]]>*/</style>-->

<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/javascript-static.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/javascript-mod.php"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/overlib.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/overlib_cssstyle.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cookies.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/ufo.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/dropdown.js"></script>  

<script type="text/javascript" defer="defer">
//<![CDATA[
setTimeout('fix_column_widths()', 20);
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
function openpopup(url,name,options,fullscreen) {
  fullurl = "http://www.whizlabs.com/examprep" + url;
  windowobj = window.open(fullurl,name,options);
  if (fullscreen) {
     windowobj.moveTo(0,0);
     windowobj.resizeTo(screen.availWidth,screen.availHeight);
  }
  windowobj.focus();
  return false;
}

function uncheckall() {
  void(d=document);
  void(el=d.getElementsByTagName('INPUT'));
  for(i=0;i<el.length;i++) {
    void(el[i].checked=0);
  }
}

function checkall() {
  void(d=document);
  void(el=d.getElementsByTagName('INPUT'));
  for(i=0;i<el.length;i++) {
    void(el[i].checked=1);
  }
}

function inserttext(text) {
  text = ' ' + text + ' ';
  if ( opener.document.forms['theform'].message.createTextRange && opener.document.forms['theform'].message.caretPos) {
    var caretPos = opener.document.forms['theform'].message.caretPos;
    caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  } else {
    opener.document.forms['theform'].message.value  += text;
  }
  opener.document.forms['theform'].message.focus();
}

function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}
//]]>
</script>
    
		<style type="text/css">
	<!--
	#main {
		min-height: 500px;
		width: 988px;
		margin: auto;
		background:#fff;
	}
	#header {
		height: 90px;
		width: 988px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/header.gif);
	}
	#navi {
		float: left;
		height: 22px;
		width: 828px;
		padding: 10px 0pt 0pt 20px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_02.gif);
	}
	#navi2 {
		height: 32px;
		width: 140px;
		float: left;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/part3left.gif);
		text-align: left;
	}
	#left {
		float: left;
		min-height: 675px;
		width: 263px;
	}
	
	#leftinsertdiv {
		float: left;
		height: 58px;
		width: 263px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-left-down_04.gif);
	}
	
	#left3 {
		float: left;
		height: 617px;
		width: 21px;
		/*background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_05.gif);*/
	}
	
	#left4 {
		height: 58px;
		width: 242px;
		float: right;
	}
	#left5 {
		float: right;
		height: 62px;
		width: 242px;
	}
	#left6 {
		float: right;
		min-height: 160px;
		width: 242px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_06-19.gif);
	}
	#right {
		float: left;
		min-height: 601px;
		width: 725px;
		background:#fff;
	}
	#leftfooter {
		float: left;
		height: 159px;
		width: 263px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/footerdiv.gif);
		background-repeat:no-repeat;
	}
	#rightfooter {
		float: left;
		height: 50px;
		width: 725px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_10-53.gif);
		background-position:left bottom;
		background-repeat:no-repeat;
		padding-top:90px;
		background-color:#fff;
	}
	#rightfooter2 {
		float: left;
		height: 19px;
		width: 725px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_54.gif);
	}
	-->
	</style>
	
<link href="./OCPJP 6 - Exam Simulator  Collections nightmare_files/css.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

<script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/document_iterator.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/find_proxy.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/get_html_text.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/global_constants.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/name_injection_builder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/number_injection_builder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/string_finder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/change_sink.js"></script><meta name="document_iterator.js"><meta name="find_proxy.js"><meta name="get_html_text.js"><meta name="global_constants.js"><meta name="name_injection_builder.js"><meta name="number_injection_builder.js"><meta name="string_finder.js"><meta name="change_sink.js"><style charset="utf-8" type="text/css" id="">SPAN.skype_pnh_container SPAN.skype_pnh_mark{  display:none !important;}@media screen{SPAN.skype_pnh_print_container_1323210120{  display:none !important;}SPAN.skype_pnh_container, SPAN.skype_pnh_container *{background-attachment: scroll !important;background-color: transparent !important;background-image: none !important;background-position: 0px 0px ! important;background-repeat: no-repeat !important;border: 0px none !important;border-color: #000000 !important;border-style: none !important;border-width: 0 !important;border-left: 0 none #000000 !important;border-top: 0 none #000000 !important;border-right: 0 none #000000 !important;border-bottom: 0 none #000000 !important;border-left-color: #000000 !important;border-left-style: none !important;border-left-width: 0 !important;border-top-color: #000000 !important;border-top-style: none !important;border-top-width: 0 !important;border-right-color: #000000 !important;border-right-style: none !important;border-right-width: 0 !important;border-bottom-color: #000000 !important;border-bottom-style: none !important;border-bottom-width: 0 !important;border-collapse: separate !important;bottom: auto !important;clear: none !important;clip: auto !important;cursor: pointer !important;direction: ltr !important;display: inline !important;float: none !important;font-style: normal !important;left: auto !important;letter-spacing: 0 !important;list-style-image: none !important;list-style-position: outside !important;list-style-type: disc !important;overflow: hidden !important;overflow-x: hidden !important;overflow-y: hidden !important;padding: 0px 0px 0px 0px !important;padding-left: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;page-break-after: auto !important;page-break-before: auto !important;page-break-inside: auto !important;position: static !important;right: auto !important;table-layout: auto !important;text-align: left !important;text-decoration: none !important;text-indent: 0px !important;text-transform: none !important;top: auto !important;voice-family: inherit !important;white-space: nowrap !important;word-spacing: normal !important;z-index: 0 !important;  color: #49535A !important;  font-family: Tahoma, Arial, Helvetica, sans-serif !important;  font-size: 11px !important;  font-weight: bold !important;  height: 14px !important;  line-height: 14px !important;  margin-left: 0px !important;  margin-top: 0px !important;  margin-right: 0px !important;  margin-bottom: 0px !important;  vertical-align: baseline !important;  width: auto !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_fax SPAN.skype_pnh_right_span, SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_fax SPAN.skype_pnh_right_span{  background-position: -92px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_dropart_flag_span{  background-position: 0px 1px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_textarea_span{  background-position: -90px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_text_span{  visibility: hidden !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_dropart_flag_span{  background-position: 0px 1px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_textarea_span{  background-position: -160px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_text_span{  background-position: -160px 0px !important;  color: #FFFFFF !important;}SPAN.skype_pnh_container SPAN.skype_pnh_left_span{  background-position: 0px 0px !important;  width: 6px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_span{  background-position: -11px 0px !important;  width: 27px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_wo_arrow_span{  background-position: -130px 0px !important;  width: 18px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_flag_span{  background-position: 1px 1px !important;  width: 18px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_textarea_span{  background-position: -125px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_text_span{  padding-left: 5px !important;  background-position: -125px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_right_span{  background-position: -62px 0px !important;  width: 15px !important;}}@media print{SPAN.skype_pnh_print_container_1323210120{}SPAN.skype_pnh_container{    display:none !important;}}@media screen{SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_common *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_inactive_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_common *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_active_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_fax *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_inactive_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_fax *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_active_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_free_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_free_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_flag_span{  background-image: url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/flags.gif') !important;}}</style></head>
<!-- WANT URL-->

<body class="mod-quiz course-11 dir-ltr lang-en_utf8" id="mod-quiz-review" onload="MM_preloadImages(&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_07.gif&#39;,&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-over_05.gif&#39;);">


<div id="main">
  <div id="header"><br>
    <p class="headertxt">Call Us at <span class="skype_pnh_print_container_1323210120">+1-818-575-6625</span><span class="skype_pnh_container" dir="ltr" tabindex="-1"><span class="skype_pnh_mark"> begin_of_the_skype_highlighting</span>&nbsp;<span class="skype_pnh_highlighting_inactive_common" dir="ltr" skypeaction="skype_dropdown" title="Call this phone number in United States of America with Skype: +18185756625"><span class="skype_pnh_left_span" skypeaction="skype_dropdown" title="Skype actions">&nbsp;&nbsp;</span><span class="skype_pnh_dropart_span" skypeaction="skype_dropdown" title="Skype actions"><span class="skype_pnh_dropart_flag_span" skypeaction="skype_dropdown" style="background-position: -5849px 1px !important; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;</span><span class="skype_pnh_textarea_span"><span class="skype_pnh_text_span">+1-818-575-6625</span></span><span class="skype_pnh_right_span">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>&nbsp;<span class="skype_pnh_mark">end_of_the_skype_highlighting</span></span> | <a href="http://www.whizlabs.com/examprep/login/logout.php?sesskey=wML6iG6GRg">Sign Out</a> | <a href="http://www.whizlabs.com/index.php?option=com_whizmart&view=cart">My Cart</a> | <a href="http://www.whizlabs.com/examprep/user/view.php">Change Password</a></p>
    <p class="txtheader">Welcome <a href="http://www.whizlabs.com/examprep">Flavio&nbsp;Vit !</a></p>
  </div>


  <div id="navi" class="breadcrumb"><h2 class="accesshide ">You are here</h2> <ul>
<li class="first"><a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/">Home</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/">My Account</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/course/view.php?id=11">OCPJP 6 - Exam Simulator</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/mod/quiz/view.php?id=2538">Collections nightmare</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> Review of attempt 2</li></ul>			<div class="navbutton">
				</div>  
  
  <div style="float:right; margin-right:60px;font-size:12px; font-weight:bold; color:#0460AD;">
  	</div>
  </div>

  <div id="navi2">
  <a href="http://www.whizlabs.com/examprep/eddy_report/performance_trak.php?cid=11" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(&#39;Image1&#39;,&#39;&#39;,&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/layerrollov.gif&#39;,1)"><img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/performace_history.gif" name="Image1" width="125" height="32" border="0" id="Image1"></a></div>
    <!-- END OF HEADER -->
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div><h2 class="main">Collections nightmare</h2><h2 class="main">Review of attempt 2</h2>



<div class="controls">
<div class="singlebutton"><form action="http://www.whizlabs.com/examprep/mod/quiz/view.php" method="get"><div><input type="hidden" name="id" value="2538"><input type="submit" value="Finish review"></div></form></div></div>
<table class="generaltable generalbox quizreviewsummary"><tbody>
<tr><th scope="row" class="cell">Started on</th><td class="cell">Thursday,  15 December 2011, 06:21 PM</td></tr>
<tr><th scope="row" class="cell">Completed on</th><td class="cell">Thursday,  15 December 2011, 07:13 PM</td></tr>
<tr><th scope="row" class="cell">Time taken</th><td class="cell">52 mins 13 secs</td></tr>
<tr><th scope="row" class="cell">Grade</th><td class="cell"><b>13.5</b> out of a maximum of 20 (<b>68</b>%)</td></tr>
</tbody></table>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%201%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10632" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                1      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements are equivalent? (Assume that navigableSet is of type NavigableSet) Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10632_50328" name="resp10632_50328" checked="checked" type="checkbox" value="50328">        </td>
        <td class="c1 text correct">
          <label for="resp10632_50328">
            <span class="anun">a<span class="anumsep">.</span></span> navigableSet.descendingIterator();            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10632_50329" name="resp10632_50329" checked="checked" type="checkbox" value="50329">        </td>
        <td class="c1 text correct">
          <label for="resp10632_50329">
            <span class="anun">b<span class="anumsep">.</span></span> navigableSet.descendingSet().iterator();            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10632_50330" name="resp10632_50330" type="checkbox" value="50330">        </td>
        <td class="c1 text ">
          <label for="resp10632_50330">
            <span class="anun">c<span class="anumsep">.</span></span> navigableSet.descendingSetIterator();            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10632_50331" name="resp10632_50331" type="checkbox" value="50331">        </td>
        <td class="c1 text ">
          <label for="resp10632_50331">
            <span class="anun">d<span class="anumsep">.</span></span> navigableSet.descending().iterator();            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and B are correct.<br><br> The descendingIterator() method returns an iterator over the elements in this set, in descending order. It is equivalent in effect to descendingSet().iterator(). <br><br>The descendingSet() method returns a reverse order view of the elements contained in this set. <br><br>Choices C and D are incorrect because such methods do not exist.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%202%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5217" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                2      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>import java.util.*; <br><br>public class Test <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">TreeMap myMap = new TreeMap(); <br>myMap.put("ab", 10); <br>myMap.put("cd", 5); <br>myMap.put("ca", 30); <br>myMap.put("az", 20); <br><br>NavigableMap myMap2 = myMap.headMap("cd", true); <br>myMap.put("bl", 100); <br>myMap.put("hi", 100); <br>myMap2.put("bi", 100); <br>System.out.println(myMap.size() + " " + myMap2.size()); <br></div>} <br></div>} <br><br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5217_22122" name="resp5217_" type="radio" value="22122">        </td>
        <td class="c1 text ">
          <label for="resp5217_22122">
            <span class="anun">a<span class="anumsep">.</span></span> Code will not compile.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5217_22123" name="resp5217_" type="radio" value="22123">        </td>
        <td class="c1 text ">
          <label for="resp5217_22123">
            <span class="anun">b<span class="anumsep">.</span></span> Throws an exception at runtime.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5217_22124" name="resp5217_" type="radio" value="22124">        </td>
        <td class="c1 text correct">
          <label for="resp5217_22124">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 7 6            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5217_22125" name="resp5217_" checked="checked" type="radio" value="22125">        </td>
        <td class="c1 text ">
          <label for="resp5217_22125">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 7 5            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>This code compiles fine and prints the output shown below. <br><br>7 6 <br><br>The TreeMap is a NavigableMap that is ordered according to the natural ordering of its keys. The headMap(toKey,inclusive) method of this class returns a view of the portion of this Map whose keys are less than (or equal to, if inclusive is true) toKey. <br><br>In this program, the value of toKey is "cd". All the keys added; "ab", "cd", "ca", "az" are within the range of "cd", so all are included in the map, myMap2, returned by the headMap method. After the method call to headMap(), two more entries are made into the original map. But only "b1" is included in myMap2 because "h1" is not less than or equal to "cd". <br><br>Finally one more entry is myMap2, for key "bi". So myMap contains the keys; "ab", "cd", "ca", "az", "b1", "h1", "bi" and myMap2 contains all of these except "h1". So the sizes of these maps are printed as 7 6. <br><br>You can read more about the NavigableMap at <br> <a href="http://www.devx.com/Java/Article/33872">http://www.devx.com/Java/Article/33872</a> <br><a href="http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html">http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%203%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5407" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                3      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile and run the following code snippet?<br><br> Hashtable table = new Hashtable();<br> table.put("Java", "Platform Independence");<br> table.put("Java", "Great Language!");<br> System.out.println("Java : " + table.get("Java"));<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5407_23025" name="resp5407_" type="radio" value="23025">        </td>
        <td class="c1 text ">
          <label for="resp5407_23025">
            <span class="anun">a<span class="anumsep">.</span></span> The code will not compile.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5407_23026" name="resp5407_" type="radio" value="23026">        </td>
        <td class="c1 text ">
          <label for="resp5407_23026">
            <span class="anun">b<span class="anumsep">.</span></span> It will print-Java : Platform Independence            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5407_23027" name="resp5407_" checked="checked" type="radio" value="23027">        </td>
        <td class="c1 text correct">
          <label for="resp5407_23027">
            <span class="anun">c<span class="anumsep">.</span></span> It will print-Java : Great Language!            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5407_23028" name="resp5407_" type="radio" value="23028">        </td>
        <td class="c1 text ">
          <label for="resp5407_23028">
            <span class="anun">d<span class="anumsep">.</span></span> It will print-Java : Platform IndependenceGreat Language!            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5407_23029" name="resp5407_" type="radio" value="23029">        </td>
        <td class="c1 text ">
          <label for="resp5407_23029">
            <span class="anun">e<span class="anumsep">.</span></span> The code will cause a runtime exception to be thrown.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> Hashtable implements the Map interface. <br><br>The put() method specified by Map states that if the map previously contained a mapping for a particular key ("Java" here), the old value would be replaced by the new value specified. Hence, "Great Language!" replaces the value "Platform Independence" for the key "Java". <br><br>Also, the put() method of Hashtable returns the previous value associated with specified key, or null if there was no mapping for the key. <br><br>Reference:<br> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Hashtable.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Hashtable.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%204%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5468" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                4      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the given code?<br><br> import java.util.*;<br> public class Sorter<br>{<br>
<div style="margin-left: 40px;"> public static void main(String[] argv)<br>{<br>
  <div style="margin-left: 40px;"> ArrayList&lt;String&gt; aList = new ArrayList&lt;String&gt;();<br> aList.add("USA");<br> aList.add("Russia");<br> aList.add("UK");<br> int pos=Collections.binarySearch(aList,"Russia"); <br>System.out.println(pos);<br></div> }<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23325" name="resp5468_" type="radio" value="23325">        </td>
        <td class="c1 text ">
          <label for="resp5468_23325">
            <span class="anun">a<span class="anumsep">.</span></span> 0            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23326" name="resp5468_" type="radio" value="23326">        </td>
        <td class="c1 text ">
          <label for="resp5468_23326">
            <span class="anun">b<span class="anumsep">.</span></span> 1            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23327" name="resp5468_" type="radio" value="23327">        </td>
        <td class="c1 text ">
          <label for="resp5468_23327">
            <span class="anun">c<span class="anumsep">.</span></span> 2            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23328" name="resp5468_" type="radio" value="23328">        </td>
        <td class="c1 text ">
          <label for="resp5468_23328">
            <span class="anun">d<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23329" name="resp5468_" checked="checked" type="radio" value="23329">        </td>
        <td class="c1 text ">
          <label for="resp5468_23329">
            <span class="anun">e<span class="anumsep">.</span></span> Exception at runtime            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23330" name="resp5468_" type="radio" value="23330">        </td>
        <td class="c1 text correct">
          <label for="resp5468_23330">
            <span class="anun">f<span class="anumsep">.</span></span> Compiles correctly, output is undefined            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice F is the correct answer.<br><br> The binarySearch method defined in the Collections class searches the specified list for the specified object using a binary search algorithm. <br><br>The list must be sorted into ascending order according to the natural ordering of its elements (as by the sort(List) method, above) prior to making this call. <br><br>If it is not sorted, the results are undefined. If the list contains multiple elements equal to the specified object, there is no guarantee which one will be found. Since the order cannot be decided, all the other choices are incorrect.<br><br.><br> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html</a></br.>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%205%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16332" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                5      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Insert the correct code at #1 so that the code compiles and runs without errors.<br><br>class Shape{}<br>class Circle extends Shape{}<br>class Rectangle extends Shape{}<br>class Generics16<br>{<br>
<div style="margin-left: 40px;">public static void main(String[] args)<br></div>
<div style="margin-left: 40px;">{<br></div>
<div style="margin-left: 80px;">#1<br>picture.add(new Circle());<br>picture.add(new Rectangle());<br>Rectangle rect = (Rectangle)picture.get(1);<br></div>
<div style="margin-left: 40px;">}<br></div>}<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16332_62119" name="resp16332_" type="radio" value="62119">        </td>
        <td class="c1 text correct">
          <label for="resp16332_62119">
            <span class="anun">a<span class="anumsep">.</span></span> Vector picture = new Vector &lt; Shape &gt; ();            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16332_62120" name="resp16332_" type="radio" value="62120">        </td>
        <td class="c1 text ">
          <label for="resp16332_62120">
            <span class="anun">b<span class="anumsep">.</span></span> Vector picture = new Vector &lt; ? &gt; ();            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16332_62121" name="resp16332_" checked="checked" type="radio" value="62121">        </td>
        <td class="c1 text ">
          <label for="resp16332_62121">
            <span class="anun">c<span class="anumsep">.</span></span> Vector picture = new Vector &lt;? extends Shape &gt;();            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Explanation:<br>Correct answer is choice A.<br><br>The wildcard character (?) indicates unknown types, so the compiler does not allow adding or inserting into such types. So Vector&lt;?&gt; and Vector&lt;? extends Shape&gt; cannot be used here.<br><br>It is allowed to assign generic types to raw types, so Vector&lt;Shape&gt; can be assigned to Vector type. However, since we use a generic class without specifying the type of its element, the compiled code is not type-safe and the compiler will issue a warning.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%206%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5399" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                6      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and executing the following code?<br><br> 1. Vector v=new Vector&lt;Integer&gt;(); <br>2. v.add(18); <br>3. v.add(20); <br>4. v.add(12); <br>5. for(int i : v) <br>6. System.out.print(i+" ");</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5399_22989" name="resp5399_" type="radio" value="22989">        </td>
        <td class="c1 text ">
          <label for="resp5399_22989">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 1            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5399_22990" name="resp5399_" type="radio" value="22990">        </td>
        <td class="c1 text ">
          <label for="resp5399_22990">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error at lines 2, 3, and 4            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5399_22991" name="resp5399_" checked="checked" type="radio" value="22991">        </td>
        <td class="c1 text correct">
          <label for="resp5399_22991">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error at line 5            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5399_22992" name="resp5399_" type="radio" value="22992">        </td>
        <td class="c1 text ">
          <label for="resp5399_22992">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 18 20 12            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>The code does not compile at line 5 because iterating through v gives elements of type Object, and Object type cannot be assigned to int or Integer variables. This happens because the declared type of v is Vector and not Vector&lt;Integer&gt;. <br><br>Choice A is incorrect because line 1 compiles without errors, it is allowed to assign generic types to raw types. <br><br>Choice B is incorrect because lines 2, 3, and 4 do compile fine, the int type values get autoboxed to Integer. <br><br>Since choice C is correct, choice D is automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%207%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5323" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                7      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>import java.util.*; <br><br>class Collection1<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br>{ <br>
  <div style="margin-left: 40px;">Set&lt;String&gt; s=new HashSet&lt;String&gt;(); <br>s.add("apple"); <br>s.add("Apple"); <br>s.add("1"); <br>s.add("1.0"); <br>String[] ss=s.toArray(); <br>for(String str : ss) <br>
    <div style="margin-left: 40px;">System.out.print(str); <br></div></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5323_22648" name="resp5323_" type="radio" value="22648">        </td>
        <td class="c1 text correct">
          <label for="resp5323_22648">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5323_22649" name="resp5323_" type="radio" value="22649">        </td>
        <td class="c1 text ">
          <label for="resp5323_22649">
            <span class="anun">b<span class="anumsep">.</span></span> Exception            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5323_22650" name="resp5323_" checked="checked" type="radio" value="22650">        </td>
        <td class="c1 text ">
          <label for="resp5323_22650">
            <span class="anun">c<span class="anumsep">.</span></span> Prints all  4 strings            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5323_22651" name="resp5323_" type="radio" value="22651">        </td>
        <td class="c1 text ">
          <label for="resp5323_22651">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "apple", "1", and "1.0"            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>The program does not compile because the toArray() method returns an object of type Object[]. The return type needs to be cast to String[] for the program to compile. <br><br>
<div style="margin-left: 40px;">String[] ss=(String[])s.toArray(); <br></div><br>Another option is to use the toArray() method which takes an argument that is the type of array to which the return type is to be cast. <br><br>
<div style="margin-left: 40px;">String[] ss=s.toArray(new String[0]); <br></div><br>Since there is a compiler error, the other choices are automatically incorrect. If the program is made to compile, all the 4 strings will be printed correctly. <br><br>Reference: <br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html</a><br><br>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%208%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5477" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                8      </div>
      </div>
  <div class="content">
    <div class="qtext">
  How would you implement the hashCode() method correctly for the class shown below? (Assume that this class implements the equals() method correctly and choose the most appropriate implementation.) <br><br>public class HashDemo <br>{ <br>
<div style="margin-left: 40px;">private Integer arr[]; <br>//other methods not shown <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5477_23370" name="resp5477_" checked="checked" type="radio" value="23370">        </td>
        <td class="c1 text correct">
          <label for="resp5477_23370">
            <span class="anun">a<span class="anumsep">.</span></span> public int hashCode()  <br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7;          <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(arr == null) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(int i=0; i&lt;arr.length; i++) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash +(arr[i] == null? 0 : arr[i].hashCode()); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash;<br>&nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5477_23371" name="resp5477_" type="radio" value="23371">        </td>
        <td class="c1 text ">
          <label for="resp5477_23371">
            <span class="anun">b<span class="anumsep">.</span></span> public int hashCode()<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(arr == null)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(int i=0; i&lt;arr.length; i++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + arr[i].hashCode();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash;<br>&nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5477_23372" name="resp5477_" type="radio" value="23372">        </td>
        <td class="c1 text ">
          <label for="resp5477_23372">
            <span class="anun">c<span class="anumsep">.</span></span> public int hashCode()<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(arr == null)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + arr.hashCode();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash;<br>&nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5477_55818" name="resp5477_" type="radio" value="55818">        </td>
        <td class="c1 text ">
          <label for="resp5477_55818">
            <span class="anun">d<span class="anumsep">.</span></span> The array should not be involved in the calculation of the hashCode() method.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>All elements of an array should be involved in the hashCode computation. Likewise, they should also be involved in the equals comparison. This is a tough question and the key lies in understanding the fact that the elements of an array are the significant data members of the class and not the array variable itself. Hence all these elements should be involved in the implementation of the hashCode() method, or equals() method for that matter. <br><br>Choice B is incorrect because it does not check whether individual elements of an array are null or not. This implementation might result in a NullPointerException if any element of an array is null. <br><br>Choice C is obviously incorrect because it invokes the hashCode() method on the array reference instead of the array elements. <br><br>From all this discussion, it is clear that choice D does not make sense. Thus, only choice A takes care of all the array elements in the calculation of the hashCode and ensures that null values are taken care of. Hence, it is the correct answer. <br><br>Want to know more? Refer to: <br><a href="http://www.javaranch.com/newsletter/Oct2002/newsletteroct2002.jsp#%7Cequalandhash">http://www.javaranch.com/newsletter/Oct2002/newsletteroct2002.jsp#|equalandhash</a> <br><a href="http://developer.java.sun.com/developer/Books/effectivejava/Chapter3.pdf">http://developer.java.sun.com/developer/Books/effectivejava/Chapter3.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%209%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5295" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                9      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements are true about the HashMap and the Hashtable classes? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5295_22507" name="resp5295_22507" type="checkbox" value="22507">        </td>
        <td class="c1 text ">
          <label for="resp5295_22507">
            <span class="anun">a<span class="anumsep">.</span></span> A HashMap is synchronized, while a Hashtable is not.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5295_22508" name="resp5295_22508" checked="checked" type="checkbox" value="22508">        </td>
        <td class="c1 text correct">
          <label for="resp5295_22508">
            <span class="anun">b<span class="anumsep">.</span></span> A Hashtable is synchronized, while a HashMap is not.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5295_22509" name="resp5295_22509" type="checkbox" value="22509">        </td>
        <td class="c1 text ">
          <label for="resp5295_22509">
            <span class="anun">c<span class="anumsep">.</span></span> A HashMap can have null values, but not null keys.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5295_22510" name="resp5295_22510" checked="checked" type="checkbox" value="22510">        </td>
        <td class="c1 text correct">
          <label for="resp5295_22510">
            <span class="anun">d<span class="anumsep">.</span></span> A Hashtable cannot have null values or null keys.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5295_22511" name="resp5295_22511" type="checkbox" value="22511">        </td>
        <td class="c1 text ">
          <label for="resp5295_22511">
            <span class="anun">e<span class="anumsep">.</span></span> A Hashtable maintains object references in the order in which they were added, while the HashMap does not.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B and D are the correct answers.<br><br> A Hashtable is synchronized, while a HashMap is not. A Hashtable cannot have null keys or values. <br><br>Choice A is incorrect because choice B is correct. <br><br>Choice C is incorrect because key or values can be null for a HashMap. Both Hashtable and HashMap do not maintain the object references in the order in which they were added. They use the hashcodes of objects for ordering. So choice E is false. <br><br>References: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashMap.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashMap.html</a> <br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Hashtable.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Hashtable.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2010%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5465" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                10      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following can read the password from the console into passwd?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5465_23313" name="resp5465_" checked="checked" type="radio" value="23313">        </td>
        <td class="c1 text correct">
          <label for="resp5465_23313">
            <span class="anun">a<span class="anumsep">.</span></span> char[] passwd = System.console().readPassword("[%s]", "Password:");            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5465_23314" name="resp5465_" type="radio" value="23314">        </td>
        <td class="c1 text ">
          <label for="resp5465_23314">
            <span class="anun">b<span class="anumsep">.</span></span> String passwd = System.console().readPassword();            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5465_23315" name="resp5465_" type="radio" value="23315">        </td>
        <td class="c1 text ">
          <label for="resp5465_23315">
            <span class="anun">c<span class="anumsep">.</span></span> char passwd = System.console().readPassword();            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5465_23316" name="resp5465_" type="radio" value="23316">        </td>
        <td class="c1 text ">
          <label for="resp5465_23316">
            <span class="anun">d<span class="anumsep">.</span></span> String passwd;  <br>&nbsp;&nbsp;&nbsp;&nbsp;System.console().readPassword(str);            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is correct. <br><br>The readPassword() method in the Console class is used to read the password from the console. It has two overloaded forms. <br>
<ul>
  <li>public char[] readPassword(String fmt, Object... args) This form provides a formatted prompt, then reads a password or passphrase from the console with echoing disabled. <br></li>
  <li>public char[] readPassword() This form reads a password or passphrase from the console with echoing disabled. <br></li>
</ul>Both forms return the password in a char array; hence choice A is correct while all the other choices are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2011%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5252" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                11      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following program? <br><br>import java.util.*; <br>1. class Shape{} <br>2. class Rect extends Shape{} <br>3. class Circle extends Shape{} <br>4. class ShadedRect extends Rect{} <br>5. class Generics2{ <br>
<div style="margin-left: 40px;">6.public static void add(List &lt;? extends Shape &gt;l,int pos,Rect r){ <br> </div>
<div style="margin-left: 80px;">7. l.add(pos,r); <br></div>
<div style="margin-left: 40px;">8. } <br></div>9. public static void main(String[] args){ <br>
<div style="margin-left: 40px;">10. List&lt;ShadedRect&gt; l=new LinkedList&lt;ShadedRect&gt;(); <br></div>
<div style="margin-left: 40px;">11. add(l,0,new ShadedRect()); <br></div>12. } <br>13. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5252_22300" name="resp5252_" type="radio" value="22300">        </td>
        <td class="c1 text ">
          <label for="resp5252_22300">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 6            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5252_22301" name="resp5252_" type="radio" value="22301">        </td>
        <td class="c1 text ">
          <label for="resp5252_22301">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error at line 11            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5252_22302" name="resp5252_" checked="checked" type="radio" value="22302">        </td>
        <td class="c1 text correct">
          <label for="resp5252_22302">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error at line 7            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5252_22303" name="resp5252_" type="radio" value="22303">        </td>
        <td class="c1 text ">
          <label for="resp5252_22303">
            <span class="anun">d<span class="anumsep">.</span></span> ClassCastException is thrown            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5252_22304" name="resp5252_" type="radio" value="22304">        </td>
        <td class="c1 text ">
          <label for="resp5252_22304">
            <span class="anun">e<span class="anumsep">.</span></span> Compiles and runs without errors            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> The code does not compile at line 7, since you cannot add objects to a collection of an unknown type. The wild card notation List &lt;? extends Shape&gt; indicates a list which can accept any kind of Shape. However, you cannot add to such a collection since the actual type is unknown at compile time. <br><br>There are no compiler errors at lines 6 and 11 because ShadedRect, is a subclass of Rect, which is a subclass of Shape. So it is legal to pass List &lt;ShadedRect&gt; as List &lt;? extends Shape&gt;. So choices A and B are incorrect. <br><br>Choices D and E are incorrect because the code does not even compile. <br><br>Check out this comprehensive tutorial on generics to learn more, <br><a href="http://java.sun.com/docs/books/tutorial/extra/generics/wildcards.html">http://java.sun.com/docs/books/tutorial/extra/generics/wildcards.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2012%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10604" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                12      </div>
      </div>
  <div class="content">
    <div class="qtext">
  You are required to store a list of songs and their respective singers, such that each song will have a singer (or singers) associated with it. Any one of these songs can be selected and played at any time. Moreover, you are also required to provide information about the last played song. <br><br>Which Java collection class is the most suitable for doing this?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50195" name="resp10604_" type="radio" value="50195">        </td>
        <td class="c1 text ">
          <label for="resp10604_50195">
            <span class="anun">a<span class="anumsep">.</span></span> java.util.ArrayList            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50196" name="resp10604_" checked="checked" type="radio" value="50196">        </td>
        <td class="c1 text correct">
          <label for="resp10604_50196">
            <span class="anun">b<span class="anumsep">.</span></span> java.util.LinkedHashMap            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50197" name="resp10604_" type="radio" value="50197">        </td>
        <td class="c1 text ">
          <label for="resp10604_50197">
            <span class="anun">c<span class="anumsep">.</span></span> java.util.IdentityHashMap            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50198" name="resp10604_" type="radio" value="50198">        </td>
        <td class="c1 text ">
          <label for="resp10604_50198">
            <span class="anun">d<span class="anumsep">.</span></span> java.util.Hashtable            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50199" name="resp10604_" type="radio" value="50199">        </td>
        <td class="c1 text ">
          <label for="resp10604_50199">
            <span class="anun">e<span class="anumsep">.</span></span> java.util.LinkedList            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.<br><br>Let's assume that the title of a song is unique.The requirement is to select a song by its title and also to map the title to the singers, so the choice of a map is ideal.The new Java class java.util.LinkedHashMap is the most appropriate class for performing the task mentioned in the question statement. This class can take care of both the requirements - <br>
<ol>
  <li>providing mapping for songs and singers, and </li>
  <li>providing information about the last played song with its Most Recently Used (MRU) cache.<br></li>
</ol>The problem statement calls for a class that will provide key-value (song-singer(s)) mapping. This requirement can be taken care of by any general purpose Map implementation, but there is an additional requirement that you need to provide information about the last played song. This can be achieved by using the java.util.LinkedHashMap class, which allows iteration through its entries in the order in which they were last accessed, from least-recently accessed to most-recently (access-order).<br><br> Choices C and D are incorrect because even though Hashtable (legacy class, synchronized) and HashMap are Map implementations, they do not maintain entries in access order. Thus they are not suitable for providing information about the last played song. <br><br>Choices A and E are incorrect because the ArrayList and the LinkedList classes are both List implementations and they do not have key-value storage. <br><br>The java.util.LinkedHashMap class, by default, maintains the entries in the order in which they were inserted, but it also provides a special constructor that allows you to specify that the entries should be maintained in the order in which they were last accessed, from least-recently accessed to most-recently accessed. <br><br>The constructor is - <br>public LinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder) <br><br>The last parameter accessOrder specifies the way the entries will be maintained. If accessOrder is true, the entries (key-value pairs) will be maintained in an order in which they were last accessed. If accessOrder is false, the entries will be maintained in the order in which they were inserted.<br><br> This is what API documentation says - <br><br>"A special constructor is provided to create a linked hash map whose order of iteration is the order in which its entries were last accessed, from least-recently accessed to most-recently (access-order). This kind of map is well-suited to building LRU caches. Invoking the put() or get() method results in an access to the corresponding entry (assuming it exists after the invocation completes). The putAll() method generates one entry access for each mapping in the specified map, in the order that key-value mappings are provided by the specified map's entry set iterator. No other methods generate entry accesses. In particular, operations on collection-views do not affect the order of iteration of the backing map."<br><br>"The example below illustrates how this problem can be solved with the help of the java.util.LinkedHashMap class".<br> <br>import java.util.LinkedHashMap;<br> public class JukeBox<br> { <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br></div>
<div style="margin-left: 80px;"> {<br> </div>
<div style="margin-left: 120px;"> // access order LinkedHashMap <br> </div>
<div style="margin-left: 120px;">LinkedHashMap songList = new LinkedHashMap(16,0.75F,true); <br> songList.put("Stoney", "Lobo");<br> songList.put("Yesterday", "Beatles");<br> songList.put("Money", "Pink Floyd");<br> songList.put("Hotel California", "Eagles"); <br>songList.put("Lonely is the night", "Air Supply"); <br>songList.put("Walk of life", "Dire Straits"); <br> <br> // more songs.... <br> // get the song and play it <br> <br> songList.get("Walk of life");<br> songList.get("Money"); <br>songList.get("Yesterday"); <br> <br> // observe the sequence of the entries <br>// Most recently accessed entry will be the last entry <br><br> System.out.println(songList);<br></div>
<div style="margin-left: 80px;"> }<br></div> } <br><br>Want to know more? You can read more about the new collection class LinkedHashMap and its usage at - <a href="http://www-106.ibm.com/developerworks/java/library/j-mer0821/">http://www-106.ibm.com/developerworks/java/library/j-mer0821/</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2013%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5285" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                13      </div>
      </div>
  <div class="content">
    <div class="qtext">
  We have the following organization of classes. <br><br>class Parent { }<br> class DerivedOne extends Parent { } <br>class DerivedTwo extends Parent { } <br><br>Which of the following statements is correct for the following expression? <br><br>Parent p = new Parent(); <br>DerivedOne d1 = new DerivedOne();<br> DerivedTwo d2 = new DerivedTwo(); <br>d1 = (DerivedOne)d2;</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5285_22460" name="resp5285_" type="radio" value="22460">        </td>
        <td class="c1 text correct">
          <label for="resp5285_22460">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5285_22461" name="resp5285_" type="radio" value="22461">        </td>
        <td class="c1 text ">
          <label for="resp5285_22461">
            <span class="anun">b<span class="anumsep">.</span></span> Compiles fine but throws RuntimeException            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5285_22462" name="resp5285_" type="radio" value="22462">        </td>
        <td class="c1 text ">
          <label for="resp5285_22462">
            <span class="anun">c<span class="anumsep">.</span></span> Compiles and runs without error            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5285_22463" name="resp5285_" checked="checked" type="radio" value="22463">        </td>
        <td class="c1 text ">
          <label for="resp5285_22463">
            <span class="anun">d<span class="anumsep">.</span></span> Compiles fine but throws ClassCastException            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> Here, DerivedOne and DerivedTwo classes inherit from the same superclass, so they are sibling objects. You cannot assign an object reference to a sibling reference, even with casting. <br><br>It is possible to assign an object to a reference variable, the variable has to be the super type of this object. So they must be part of the same inheritance hierarchy. Since the program does not even compile, the other choices are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2014%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10602" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                14      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>import java.util.*; <br>class Gen&lt;T&gt; <br>{<br>
<div style="margin-left: 40px;"> T obj; <br>Gen(T o)<br>{ <br>
  <div style="margin-left: 40px;">obj=o; <br></div>} <br>T get() <br>{ <br>
  <div style="margin-left: 40px;">return obj; <br></div>}<br></div> }<br><br>class Generics19<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br>{ <br>
  <div style="margin-left: 40px;">Gen&lt;Integer&gt; i1=new Gen&lt;Integer&gt;(new Integer(10)); <br>int i=i1.get(); <br>System.out.println(i); <br></div>}<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10602_50187" name="resp10602_" type="radio" value="50187">        </td>
        <td class="c1 text ">
          <label for="resp10602_50187">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10602_50188" name="resp10602_" type="radio" value="50188">        </td>
        <td class="c1 text ">
          <label for="resp10602_50188">
            <span class="anun">b<span class="anumsep">.</span></span> Exception            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10602_50189" name="resp10602_" checked="checked" type="radio" value="50189">        </td>
        <td class="c1 text correct">
          <label for="resp10602_50189">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 10            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10602_50190" name="resp10602_" type="radio" value="50190">        </td>
        <td class="c1 text ">
          <label for="resp10602_50190">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 0            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> The Gen class is a generic class, T is the name of a type parameter to which we can assign any type. Here, we pass Integer as the type argument value for T. <br><br>Gen&lt;Integer&gt; i1=new Gen&lt;Integer&gt;(new Integer(10));<br><br> The return type of the get() method is Integer, but we can receive it in an int variable because Integer unboxes into int. So the value received in i is 10. Thus, the output is 10. Hence, choice D is incorrect. <br><br>There are no compiler errors or exceptions generated here, so choices A and B are incorrect.<br><br> For more information, check out<br><a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf">http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2015%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16301" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                15      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen if the following code is compiled.<br><br>ArrayList&lt;String&gt; l = new ArrayList&lt;String&gt;(); #1<br><br>l1= Collections.synchronizedList(l); #2<br><br>String[] s=l1.toArray ; #3</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16301_61981" name="resp16301_" type="radio" value="61981">        </td>
        <td class="c1 text ">
          <label for="resp16301_61981">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation Error at #1.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16301_61982" name="resp16301_" type="radio" value="61982">        </td>
        <td class="c1 text ">
          <label for="resp16301_61982">
            <span class="anun">b<span class="anumsep">.</span></span> Compilation Error at #2.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16301_61983" name="resp16301_" type="radio" value="61983">        </td>
        <td class="c1 text ">
          <label for="resp16301_61983">
            <span class="anun">c<span class="anumsep">.</span></span> Compilation Error at #3.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16301_61984" name="resp16301_" checked="checked" type="radio" value="61984">        </td>
        <td class="c1 text correct">
          <label for="resp16301_61984">
            <span class="anun">d<span class="anumsep">.</span></span> No compilation issues.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : D<br><br>Explanation:<br>The static method Collections.synchronizedList(List list) returns a synchronized (thread-safe) list backed by the specified list. Since the return type of this method is List, the return value has to be received in a variable of type List&lt;String&gt; and not ArrayList&lt;String&gt;. <br><br>The toArray method returns an array containing all the elements in this collection; the runtime type of the returned array is that of the specified array. In this case, since we pass new String[0] to the toArray method, it returns an array of String.<br><br>Reference:<br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2016%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10607" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                16      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and executing the following code ? <br><br>import java.util.*;<br>class Gen&lt;T&gt; <br>{<br>
<div style="margin-left: 40px;"> T obj; <br>Gen(T o)<br>{ <br>
  <div style="margin-left: 40px;">obj=o; <br></div>}<br> T get()<br> {<br>
  <div style="margin-left: 40px;"> return obj;<br></div> } <br></div>}<br><br> class Generics20<br>{<br>
<div style="margin-left: 40px;"> public static void main(String[] args)<br>{<br>
  <div style="margin-left: 40px;"> Gen&lt;Integer&gt; i1=new Gen&lt;Integer&gt;(new Integer(18)); // line1<br> Gen&lt;Integer&gt; i2=new Gen&lt;Integer&gt;(18); //line2<br> System.out.print(i1.get()==i2.get()); //line 3<br> System.out.print(i1.get().intValue()==i2.get().intValue()); //line 4<br></div> } <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50210" name="resp10607_" type="radio" value="50210">        </td>
        <td class="c1 text ">
          <label for="resp10607_50210">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 1            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50211" name="resp10607_" type="radio" value="50211">        </td>
        <td class="c1 text ">
          <label for="resp10607_50211">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error at line 2            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50212" name="resp10607_" type="radio" value="50212">        </td>
        <td class="c1 text ">
          <label for="resp10607_50212">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error at line 4            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50213" name="resp10607_" checked="checked" type="radio" value="50213">        </td>
        <td class="c1 text correct">
          <label for="resp10607_50213">
            <span class="anun">d<span class="anumsep">.</span></span> Prints false true            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50214" name="resp10607_" type="radio" value="50214">        </td>
        <td class="c1 text ">
          <label for="resp10607_50214">
            <span class="anun">e<span class="anumsep">.</span></span> Prints false false            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50215" name="resp10607_" type="radio" value="50215">        </td>
        <td class="c1 text ">
          <label for="resp10607_50215">
            <span class="anun">f<span class="anumsep">.</span></span> Prints true true            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> Gen is a generic class. Here, Integer is a type argument that is passed to Gen's type parameter T. <br><br>Gen&lt;Integer&gt; i2=new Gen&lt;Integer&gt;(18);<br><br> In the above statement, autoboxing is used to encapsulate the value 18. So this is equivalent to the following statement: <br><br>Gen&lt;Integer&gt; i1=new Gen&lt;Integer&gt;(new Integer(18));<br><br> So there are no compiler errors in these statements. In line 3, we are comparing the object references returned by the get() method calls. Thus, the result is false. <br><br>Line 4 compares the int values encapsulated by the 2 Integer objects. Since both values are 18, the result is true. So choice D is correct.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2017%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16275" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                17      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output when the following code is run.<br><br>ArrayList<string> a=new ArrayList<string>(); <br>a.add("1"); <br> a.add("2");<br>a.add("1"); <br>String[] s=a.toArray(new String[0]); <br>for(String str:s) System.out.print(str); </string></string></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16275_61868" name="resp16275_" type="radio" value="61868">        </td>
        <td class="c1 text ">
          <label for="resp16275_61868">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation error.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16275_61869" name="resp16275_" type="radio" value="61869">        </td>
        <td class="c1 text ">
          <label for="resp16275_61869">
            <span class="anun">b<span class="anumsep">.</span></span> Exception at runtime .            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16275_61870" name="resp16275_" checked="checked" type="radio" value="61870">        </td>
        <td class="c1 text correct">
          <label for="resp16275_61870">
            <span class="anun">c<span class="anumsep">.</span></span> 121 .            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16275_61871" name="resp16275_" type="radio" value="61871">        </td>
        <td class="c1 text ">
          <label for="resp16275_61871">
            <span class="anun">d<span class="anumsep">.</span></span> 1            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : C <br><br>Explanation: <br>The toArray method defined in the Collection interface is used to convert a collection to an array. The overloaded version of toArray method used in this code takes an argument, which is the type of array to which the return type is to be cast. <br><br>String[] s=a.toArray(new String[0]); The contents of the String array are then printed. <br><br>Reference: <br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html </a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2018%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5397" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                18      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which interface defines the int compare(Object, Object) method?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5397_22979" name="resp5397_" type="radio" value="22979">        </td>
        <td class="c1 text correct">
          <label for="resp5397_22979">
            <span class="anun">a<span class="anumsep">.</span></span> Comparator            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5397_22980" name="resp5397_" checked="checked" type="radio" value="22980">        </td>
        <td class="c1 text ">
          <label for="resp5397_22980">
            <span class="anun">b<span class="anumsep">.</span></span> Comparable            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5397_22981" name="resp5397_" type="radio" value="22981">        </td>
        <td class="c1 text ">
          <label for="resp5397_22981">
            <span class="anun">c<span class="anumsep">.</span></span> SortedSet            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5397_22982" name="resp5397_" type="radio" value="22982">        </td>
        <td class="c1 text ">
          <label for="resp5397_22982">
            <span class="anun">d<span class="anumsep">.</span></span> TreeMap            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> The java.lang.Comparator interface defines the compare method whose signature is <br><br>
<div style="margin-left: 40px;">int compare(Object o1, Object o2) <br></div><br>A comparator can be used to define total ordering of objects in a collection, based on the result of the compare method. So choice A is correct. <br><br>Comparable interface imposes a total ordering on the objects of each class that implements it. The method defined by it is int compareTo(Object). So choice B is incorrect. <br><br>The SortedSet interface represents a Set, whose elements can be iterated in a sorted order. It does not define the compare method. So choice C is incorrect. <br><br>Choice D is also incorrect since TreeMap is a class and not an interface. Moreover, it does not define any method called compare. <br><br>Reference: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2019%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5339" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                19      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements are true about a Map object? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5339_22718" name="resp5339_22718" type="checkbox" value="22718">        </td>
        <td class="c1 text correct">
          <label for="resp5339_22718">
            <span class="anun">a<span class="anumsep">.</span></span> It cannot be assigned to a reference variable of type Collection.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5339_22719" name="resp5339_22719" type="checkbox" value="22719">        </td>
        <td class="c1 text ">
          <label for="resp5339_22719">
            <span class="anun">b<span class="anumsep">.</span></span> It maps unique keys to unique values.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5339_22720" name="resp5339_22720" checked="checked" type="checkbox" value="22720">        </td>
        <td class="c1 text correct">
          <label for="resp5339_22720">
            <span class="anun">c<span class="anumsep">.</span></span> It maps unique keys to non-unique values.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5339_22721" name="resp5339_22721" type="checkbox" value="22721">        </td>
        <td class="c1 text ">
          <label for="resp5339_22721">
            <span class="anun">d<span class="anumsep">.</span></span> It can be iterated using the MapIterator.            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and C are the correct answers.<br><br> The Map interface does not extend the Collection interface, so Map objects cannot be assigned to a reference variable of type Collection. <br><br>A Map object maps unique keys to values, which may be duplicated. So choice C is correct, while choice B is incorrect. <br><br>Choice D is incorrect because there is no type called MapIterator.      </div>
        <div class="grading">
      <div class="correctness  partiallycorrect">Partially correct</div><div class="gradingdetails">Marks for this submission: 0.5/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2020%20of%20Quiz%20Collections%20nightmare%20(ID:%202098),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5388" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                20      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code?<br><br> ConcurrentNavigableMap myMap = new ConcurrentSkipListMap();<br> myMap.put("ab", 10);<br> myMap.put("cd", 5);<br> myMap.put("ca", 30);<br> myMap.put("c", 30);<br> myMap.put("az", 20);<br> NavigableMap myMap2 = myMap.tailMap("c", true);<br> System.out.println(myMap.size() + " " + myMap2.size());<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5388_22938" name="resp5388_" type="radio" value="22938">        </td>
        <td class="c1 text ">
          <label for="resp5388_22938">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5388_22939" name="resp5388_" type="radio" value="22939">        </td>
        <td class="c1 text ">
          <label for="resp5388_22939">
            <span class="anun">b<span class="anumsep">.</span></span> Exception            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5388_22940" name="resp5388_" checked="checked" type="radio" value="22940">        </td>
        <td class="c1 text correct">
          <label for="resp5388_22940">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 5 3            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5388_22941" name="resp5388_" type="radio" value="22941">        </td>
        <td class="c1 text ">
          <label for="resp5388_22941">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 5 2            <img src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is correct.<br><br> The tailMap(fromKey) method defined in NavigableMap returns a view of the portion of this map whose keys are greater than or equal to fromKey. Here, the key is "c", hence the map view returned contains "c","ca" and "cd". <br><br>Since the main map contains 5 elements and the view contains 3 elements, the output is 5 3. Since the code compiles and runs correctly, all the other choices are incorrect. <br><br>For more information, refer to <br><a href="http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html">http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>

<div class="controls">
<div class="singlebutton"><form action="http://www.whizlabs.com/examprep/mod/quiz/view.php" method="get"><div><input type="hidden" name="id" value="2538"><input type="submit" value="Finish review"></div></form></div></div>
<!--Start - Display Buttons with their course prices in each moodle pages: Devesh M-->
				
		<!--Start - Display Buy Mock Exam Full Version button with price at trial course page only: Devesh M-->
				<!--End - Display Buy Mock Exam Full Version button with price at trial course page only: Devesh M-->
  <div id="leftfooter" style="display: none; "></div><div id="rightfooter" style="display: none; "><p class="footertopma">Thanks Whizlabs for such an excellent product. It really helped me a lot for my achivement. -Nazmul<span class="more"><a href="http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170459&showall=true#" class="amore"> more</a></span></p>

  </div>

  <div id="rightfooter2" style="display: none; "><p class="copyright">Whizlabs Copyright (C) 2011. All Rights Reserved.</p></div>
<script language="javascript">
	if(document.getElementById("left-column")) {
	
	}
	else {
		document.getElementById('leftfooter').style.display='none';
		document.getElementById('rightfooter').style.display='none';
		document.getElementById('rightfooter2').style.display='none';
	}
</script>
  <div id="footerbottom">
    
 <center>
	<div style="border:0px solid #FFFFFF; font-size:11px; font-family:Arial, Helvetica, sans-serif; font-weight:bold; color:#000;">
		<br>
		<span><a href="http://www.whizlabs.com/scja/scja.html" title="SCJA Certification" style="text-decoration:none; color:#000;">SCJA Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scjp/scjp.html" title="SCJP Certification" style="text-decoration:none; color:#000;">SCJP Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scwcd/scwcd.html" title="SCWCD Certification" style="text-decoration:none; color:#000;">SCWCD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scbcd/scbcd.html" title="SCBCD Certification" style="text-decoration:none; color:#000;">SCBCD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scdjws/scdjws.html" title="SCDJWS Certification" style="text-decoration:none; color:#000;">SCDJWS Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scmad/scmad.html" title="SCMAD Certification" style="text-decoration:none; color:#000;">SCMAD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scea/scea.html" title="SCEA Certification" style="text-decoration:none; color:#000;">SCEA Certification</a></span>

		<br><br>
		<span><a href="http://www.whizlabs.com/otherpages/legal.html" alt="coming soon" style="text-decoration:none; color:#000;">Legal</a></span> |
		<span><a href="http://www.whizlabs.com/otherpages/policies.html" alt="coming soon" style="text-decoration:none; color:#000;">Policies</a></span> |
		<span><a href="http://www.whizlabs.com/otherpages/copyrights-and-trademarks.html" alt="coming soon" style="text-decoration:none; color:#000;"> Copyrights and Trademarks</a></span>
	</div>
	<br>
</center>
</div>
 </div>

<!--End - Display Buttons with their course prices in each moodle pages: Devesh M-->
<!--Footer links for each moodle pages-->


<!--Google Adwords Code Start: Devesh M-->
	<!--quiz/review.php--> 
	<!-- Google Code for Trial Test Reviewed Conversion Page --> 
	<script type="text/javascript">
	<!--
	var google_conversion_id = 1071861065;
	var google_conversion_language = "en";
	var google_conversion_format = "2";
	var google_conversion_color = "ffffff";
	var google_conversion_label = "YhFjCNjMogEQyZqN_wM"; var google_conversion_value = 0; //--> </script> <script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/conversion.js">
	</script><iframe name="google_conversion_frame" width="200" height="26" src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/saved_resource.htm" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no">&lt;img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1071861065/?frame=0&amp;random=1324001696905&amp;cv=7&amp;fst=1324001696905&amp;num=1&amp;fmt=2&amp;value=0&amp;label=YhFjCNjMogEQyZqN_wM&amp;bg=ffffff&amp;hl=en&amp;guid=ON&amp;u_h=1080&amp;u_w=1920&amp;u_ah=1080&amp;u_aw=1920&amp;u_cd=32&amp;u_his=39&amp;u_tz=-120&amp;u_java=true&amp;u_nplug=27&amp;u_nmime=117&amp;ref=http%3A//www.whizlabs.com/examprep/mod/quiz/review.php%3Fattempt%3D170459&amp;url=http%3A//www.whizlabs.com/examprep/mod/quiz/review.php%3Fattempt%3D170459%26showall%3Dtrue" /&gt;</iframe>
	<noscript>
	&lt;div style="display:inline;"&gt;
	&lt;img height="1" width="1" style="border-style:none;" alt=""
	src="http://www.googleadservices.com/pagead/conversion/1071861065/?label=YhF
	jCNjMogEQyZqN_wM&amp;amp;guid=ON&amp;amp;script=0"/&gt;
	&lt;/div&gt;
	</noscript>
<!--Google Adwords Code End : Devesh M-->

<!--OnTarget Code Start: Devesh M-->
<script language="JavaScript">
	var s_PageName = "OCPJP 6 - Exam Simulator: Collections nightmare";

			</script>

<!--End of OnTarget Code: Devesh M-->

<!-- Start of Google Analytics Code: Devesh M-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="./OCPJP 6 - Exam Simulator  Collections nightmare_files/ga.js" type="text/javascript"></script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-320509-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<!--End of Google Analytics Code: Devesh M-->



</body><span id="skype_highlighting_settings" display="none" autoextractnumbers="1"></span><object id="skype_plugin_object" location.href="http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170459&amp;showall=true" location.hostname="www.whizlabs.com" style="position: absolute; visibility: hidden; left: -100px; top: -100px; " width="0" height="0" type="application/x-vnd.skype.click2call.chrome.5.6.0"></object></html>